package com.eureka.healthprovider;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.Status;
import org.springframework.stereotype.Component;

/**
 * 健康指示器
 *
 */
@Component
public class MyHealthIndicator implements HealthIndicator {


    @Override
    public Health health() {
        //覆盖方法，根据当前状态判断系统是否正常
        //模仿读取数据库判断是否连接成功
        if ( DataBaseConstants.isStatus() ){
            return new Health.Builder(Status.UP).build();
        }
        //返回错误
        return new Health.Builder(Status.DOWN).build();
    }
}
